- /* sxfbexpx.cpp by K.Tsuru */
- // function ID 5205 BRADIX(reference)
- /*****************
- SDecimal class
- exp(x) by series
- ******************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static const char* func = "BexpSeries";
- SDecimal BexpSeries(const SDouble& x){
- int e = x.NetRdxExp();
- int xsgn;
- if( (xsgn = x.Sign(5205)) == 0) return x;
- if( e > 0){ // x > 1
- x.SetError(x.OUT_OF_RANGE, func, 5205);
- }
-
- SDecimal sum(1.0), xf, delta;
- xf = xf.ConvToBin(x);
- ulong mt = delta.SlOpMaxValue(), k = 2;
-
- // sum = 1 + x;
- if(xsgn < 0 ){
- xf.ChangeSign(); XXSub(sum, xf, sum); // xf = |x|
- } else XXAdd(sum, xf, sum);
- delta = xf;
-
- while(delta.Sign()){
- XsDiv(delta*xf, k, delta);
- if((xsgn < 0) && (k & 1)) XXSub(sum, delta, sum);
- else XXAdd(sum, delta, sum);
- if( (k++) >= mt ){
- sum.SetError(sum.NOT_CONVERGE, func, -5205);
- break;
- }
- }
- return sum;
- }
sxfbexpx.cpp : last modifiled at 2015/12/15 13:59:15(901 bytes)
created at 2015/12/22 16:09:56
The creation time of this html file is 2017/10/27 15:45:59 (Fri Oct 27 15:45:59 2017).